package com.clip.action;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;

@Deprecated
public class DayViewAction extends ActionSupport{
//
//	private static final long serialVersionUID = -6314159879163213159L;
//	
//	@Autowired
//	private EventService eventService;
//	
//	public void getPrevMonth(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar = Calendar.getInstance();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, this.year);
//		calendar.set(Calendar.MONTH, this.month);
//		calendar.set(Calendar.DAY_OF_MONTH, this.day);
//		calendar.add(Calendar.MONTH, -1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int day = calendar.get(Calendar.DAY_OF_MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("day", day);
//		jsonMap.put("maxday", maxday);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getPrevDay(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar = Calendar.getInstance();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, this.year);
//		calendar.set(Calendar.MONTH, this.month);
//		calendar.set(Calendar.DAY_OF_MONTH, this.day);
//		calendar.add(Calendar.DAY_OF_MONTH, -1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int day = calendar.get(Calendar.DAY_OF_MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("day", day);
//		jsonMap.put("maxday", maxday);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getUserDefinedDay(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar = Calendar.getInstance();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, this.year);
//		calendar.set(Calendar.MONTH, this.month);
//		calendar.set(Calendar.DAY_OF_MONTH, this.day);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int day = calendar.get(Calendar.DAY_OF_MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("day", day);
//		jsonMap.put("maxday", maxday);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getNextDay(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar = Calendar.getInstance();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, this.year);
//		calendar.set(Calendar.MONTH, this.month);
//		calendar.set(Calendar.DAY_OF_MONTH, this.day);
//		calendar.add(Calendar.DAY_OF_MONTH, +1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int day = calendar.get(Calendar.DAY_OF_MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("day", day);
//		jsonMap.put("maxday", maxday);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getNextMonth(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar = Calendar.getInstance();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		calendar.set(Calendar.YEAR, this.year);
//		calendar.set(Calendar.MONTH, this.month);
//		calendar.set(Calendar.DAY_OF_MONTH, this.day);
//		calendar.add(Calendar.MONTH, +1);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int day = calendar.get(Calendar.DAY_OF_MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("day", day);
//		jsonMap.put("maxday", maxday);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	
//	public void getThisDay(){
//		Map<String,Object> jsonMap = new HashMap<String, Object>();
//		Calendar calendar = Calendar.getInstance();
//		calendar.clear(Calendar.MILLISECOND);
//		calendar.clear(Calendar.SECOND);
//		calendar.clear(Calendar.MINUTE);
//		calendar.set(Calendar.HOUR_OF_DAY, 0);
//		int year = calendar.get(Calendar.YEAR);
//		int month = calendar.get(Calendar.MONTH);
//		int day = calendar.get(Calendar.DAY_OF_MONTH);
//		int maxday = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
//		
//		jsonMap.put("year", year);
//		jsonMap.put("month", month);
//		jsonMap.put("day", day);
//		jsonMap.put("maxday", maxday);
//		
//		String jsonStr = com.clip.util.json.JSONObject.toJSONString(jsonMap);
//		Struts2Utils.renderText(jsonStr);
//	}
//	public void getEventsByDay(){
//		Calendar calendar = Calendar.getInstance();
//		User currentUser = (User) Struts2Utils.getSession().getAttribute(SessionAttributeKey.USER);
//		this.year = this.year==0 ? calendar.get(Calendar.YEAR) : this.year;
//		this.month = this.month==0 ? calendar.get(Calendar.MONTH) : this.month;
//		this.day = this.day==0 ? calendar.get(Calendar.DAY_OF_MONTH) : this.day;
//		List events1 = eventService.getEventsByDay(this.year,this.month,this.day,calendar,currentUser);
//		Map<String,Map> returnmap=organizeDayViewMapAsXml(events1,currentUser);
//		Struts2Utils.renderXml(ToolsUtils.getDOM(returnmap));
//	}
//	private Map<String,Map> organizeDayViewMapAsXml(List list, User user) {
//		Map<String, Map> returnMap=new LinkedHashMap<String, Map>();
//		Calendar firstDateOfMonth=Calendar.getInstance();
//		firstDateOfMonth.clear(Calendar.MILLISECOND);
//		firstDateOfMonth.clear(Calendar.SECOND);
//		firstDateOfMonth.clear(Calendar.MINUTE);
//		firstDateOfMonth.set(Calendar.HOUR_OF_DAY, 0);
//		firstDateOfMonth.set(Calendar.YEAR, year);
//		firstDateOfMonth.set(Calendar.MONTH, month);
//		firstDateOfMonth.set(Calendar.DAY_OF_MONTH, day);
//		Calendar lastDateOfMonth=(Calendar) firstDateOfMonth.clone();
//		lastDateOfMonth.add(Calendar.DAY_OF_MONTH,+1);
//		lastDateOfMonth.add(Calendar.HOUR_OF_DAY, -1);
//		for (Object object : list) {
//			EventForView eventforview=(EventForView) object;
//			Map<String,Object> temp2=new HashMap<String,Object>();
//			temp2.put("eventid", eventforview.getEventid());
//			temp2.put("isClocked", ""+eventforview.isClocked());
//			temp2.put("isThisMonth", ""+eventforview.isThisMonth());
//			temp2.put("eventtype", eventforview.getEventtype());
//			temp2.put("starttime", eventforview.getStarttime().toString());
//			temp2.put("endtime", eventforview.getEndtime().toString());
//			temp2.put("iswholeday", eventforview.getIswholeday().toString());
//			temp2.put("content", eventforview.getContent());
//			temp2.put("clocktime", eventforview.getClocktime()==null?"":eventforview.getClocktime());
//			temp2.put("address",eventforview.getAddress());
//			temp2.put("title", eventforview.getTitle());
//			temp2.put("startday", getStartDayOfDay(eventforview.getStarttime(),firstDateOfMonth));
//			temp2.put("endday", getEndDayOfDay(eventforview.getEndtime(),lastDateOfMonth));
//			temp2.put("deadlinetime", eventforview.getDeadlinetime().toString());
//			temp2.put("reliedclip", eventforview.getReliedclip().toString());
//			temp2.put("isvip", eventforview.getIsvip().toString());
//			temp2.put("istodayortommorrow", ""+eventforview.isTodayOrTommorrow());
//			temp2.put("processstatus", eventforview.getProcessstatus().toString());
//			temp2.put("publishname", eventforview.getPublishname());
//			temp2.put("forwardname", eventforview.getForwardname());
//			temp2.put("puid", eventforview.getPuid());
//			temp2.put("fuid", eventforview.getFuid());
//			temp2.put("cliptype", eventforview.getCliptype());
//			//temp2.put("date", firstDateOfWeek.getTimeInMillis());
//			returnMap.put("EventForView id="+eventforview.getEventid(), temp2);
//		}
//		return returnMap;
//	}
//	private Integer getStartDayOfDay(Long starttime,Calendar firstDateOfMonth){
//		if(starttime<firstDateOfMonth.getTimeInMillis()){
//			return 0;
//		}else{
//			Calendar calendar=Calendar.getInstance();
//			calendar.setTimeInMillis(starttime);
//			return calendar.get(Calendar.HOUR_OF_DAY);
//		}
//	}
//	private Integer getEndDayOfDay(Long endtime,Calendar lastDateOfMonth){
//		if(endtime>lastDateOfMonth.getTimeInMillis()){
//			return lastDateOfMonth.getActualMaximum(Calendar.HOUR_OF_DAY)+1;
//		}else{
//			Calendar calendar=Calendar.getInstance();
//			calendar.setTimeInMillis(endtime);
//			return calendar.get(Calendar.HOUR_OF_DAY)+1;
//		}
//	}
//	public void acceptInvitedClip(){
//		HttpServletRequest request=Struts2Utils.getRequest();
//		User currentUser=(User) Struts2Utils.getSession().getAttribute(SessionAttributeKey.USER);
//		ClipEvent clipEvent=this.eventService.acceptInvitedClip(currentUser,eventid);
//		if(currentUser==null||currentUser.getId()<=0||clipEvent==null||clipEvent.getId()<=0)
//			Struts2Utils.renderText("");
//		Calendar firstDateOfDay=Calendar.getInstance();
//		firstDateOfDay.clear(Calendar.MILLISECOND);
//		firstDateOfDay.clear(Calendar.SECOND);
//		firstDateOfDay.clear(Calendar.MINUTE);
//		firstDateOfDay.set(Calendar.HOUR_OF_DAY, 0);
//		firstDateOfDay.set(Calendar.YEAR, this.year);
//		firstDateOfDay.set(Calendar.MONTH,this.month);
//		firstDateOfDay.set(Calendar.DAY_OF_MONTH,this.day);
//		Calendar endDateOfDay=(Calendar) firstDateOfDay.clone();
//		endDateOfDay.add(Calendar.DAY_OF_MONTH,+1);
//		Map reMap=new HashMap();
//		reMap.put("eventid", clipEvent.getId());
//		reMap.put("title", clipEvent.getTitle());
//		reMap.put("address", clipEvent.getAddress()==null||clipEvent.getAddress().length()==0?"":ToolsUtils.xmlCDATA(clipEvent.getAddress()));
//		String content=clipEvent.getContent();
//		reMap.put("content", content==null||content.length()==0?"":ToolsUtils.xmlCDATA(URLReplace.replace(content)));
//		reMap.put("eventtype", ClipEvent.eventtypeInt2Str(clipEvent.getEventtype()));
//		reMap.put("starttime", clipEvent.getBegintime());
//		reMap.put("endtime", clipEvent.getEndtime());
//		reMap.put("iswholeday", clipEvent.getIswholeday());
//		reMap.put("clocktime", clipEvent.getAlerttime());
////		reMap.put("deadlinetime", clipEvent.getDeadlinetime());
//		reMap.put("reliedclip", clipEvent.getReliedclip());
//		reMap.put("isvip", clipEvent.getIsvip());
//		reMap.put("processstatus", clipEvent.getProcessstatus());
////		List<String> names=this.eventService.getPublishname(clipEvent,currentUser);
////		if(names.size()>0){
////			reMap.put("publishname", names.get(0));
////			if(names.size()>1)
////				reMap.put("forwardname", names.get(1));
////		}
//		//(clip.begintime<="+begin+" and clip.endtime>="+begin+") or (clip.begintime>"+begin+" and clip.begintime<"+end+")) 
//		if(isBelongPassage(firstDateOfDay,endDateOfDay,clipEvent)){
//			reMap.put("iscrtweek", 1);
//			reMap.put("startday",getStartDayOfDay(clipEvent.getBegintime(),firstDateOfDay));
//			reMap.put("endday",getEndDayOfDay(clipEvent.getEndtime(),endDateOfDay));
//		}else{
//			reMap.put("iscrtweek",0);
//		}
//		Struts2Utils.renderXml(ToolsUtils.getDOM(reMap));
//	}
//	
//	private boolean isBelongPassage(Calendar passageBegin,Calendar passageEnd,ClipEvent clipEvent){
//		if((clipEvent.getBegintime()<=passageBegin.getTimeInMillis() && clipEvent.getEndtime()>=passageBegin.getTimeInMillis())
//				||(clipEvent.getBegintime()>passageBegin.getTimeInMillis()&&clipEvent.getBegintime()<passageEnd.getTimeInMillis())){
//			return true;
//		}else{
//			return false;
//		}
//	}
//////	@Autowired
//////	private MemoEventService memoEventService;
//////	@Autowired
//////	private ClockEventService clockEventService;
//////	@Autowired
//////	private DateEventService dateEventService;
////	
////	
////	
////	public void setDayToView(){
////		HttpSession session=Struts2Utils.getSession();
////		session.setAttribute(SessionAttributeKey.TOVIEWDAY, stringDay);
////		Struts2Utils.renderText("{result:1}");
////	}
////	
////	public void getEventsToDayView(){
////		HttpSession session=Struts2Utils.getSession();
////		Calendar calendar=Calendar.getInstance();
////		Calendar getdate=Calendar.getInstance();
////		getdate.set(Calendar.YEAR, year);
////		getdate.set(Calendar.MONTH, month);
////		getdate.set(Calendar.DAY_OF_MONTH, day);
////		boolean isThisMonth=false;
////		if(calendar.get(Calendar.YEAR)==getdate.get(Calendar.YEAR)&&calendar.get(Calendar.MONTH)==getdate.get(Calendar.MONTH)){
////			isThisMonth=true;
////		}
////		User currentUser=(User) session.getAttribute(SessionAttributeKey.USER);
////		List<EventForView> memos=this.memoEventService.getEventsByDay(getdate, calendar, currentUser, isThisMonth);
////		List<EventForView> clocks=this.clockEventService.getEventsByDay(getdate, calendar, currentUser, isThisMonth);
////		List<EventForView> dates=this.dateEventService.getEventsByDay(getdate, calendar, currentUser, isThisMonth);
////		memos.addAll(clocks);
////		memos.addAll(dates);
////		Collections.sort(memos, new EventForViewCompare());
////		Struts2Utils.renderXml(ToolsUtils.getDOMEventForView(memos));
////	}
////	
////	public void getTodayDateInfo(){
////		Calendar getdate=Calendar.getInstance();
////		Map<String,Object> infoMap=new LinkedHashMap<String,Object>();
////		infoMap.put("year", getdate.get(Calendar.YEAR));
////		infoMap.put("month", getdate.get(Calendar.MONTH));
////		infoMap.put("day", getdate.get(Calendar.DAY_OF_MONTH));
////		infoMap.put("week", getdate.get(Calendar.WEEK_OF_YEAR));
////		Struts2Utils.renderText(ToolsUtils.getJSON(infoMap));
////	}
////	
////	public void getDateInfo(){
////		Calendar getdate=Calendar.getInstance();
////		if(year==0&&month==0&&day==0){
////			
////			HttpSession session=Struts2Utils.getSession();
////			String strDay=(String) session.getAttribute(SessionAttributeKey.TOVIEWDAY);
////			Date date=null;
////			if(strDay!=null&&strDay.length()>0){
////				session.removeAttribute(SessionAttributeKey.TOVIEWDAY);
////				DateFormat format= new SimpleDateFormat("yyyy年MM月dd日");
////				
////				try {
////					date=format.parse(strDay);
////				} catch (ParseException e) {
////					date=new Date();
////				}
////			}else{
////				date=new Date();
////			}
////			getdate.setTime(date);
////		}else{
////			getdate.set(Calendar.YEAR, year);
////			getdate.set(Calendar.MONTH, month);
////			getdate.set(Calendar.DAY_OF_MONTH, day);
////		}
////		Map<String,Object> infoMap=new LinkedHashMap<String,Object>();
////		infoMap.put("year", getdate.get(Calendar.YEAR));
////		infoMap.put("month", getdate.get(Calendar.MONTH));
////		infoMap.put("day", getdate.get(Calendar.DAY_OF_MONTH));
////		infoMap.put("week", getdate.get(Calendar.WEEK_OF_YEAR));
////		Struts2Utils.renderText(ToolsUtils.getJSON(infoMap));
////	}
////	
////	private String stringDay;
////
////	public String getStringDay() {
////		return stringDay;
////	}
////
////	public void setStringDay(String stringDay) {
////		this.stringDay = stringDay;
////	}
////	
//	private int year;
//	private int month;
//	private int day;
//	private int eventid;
//
//	public int getYear() {
//		return year;
//	}
//
//	public void setYear(int year) {
//		this.year = year;
//	}
//
//	public int getMonth() {
//		return month;
//	}
//	public void setMonth(int month) {
//		this.month = month;
//	}
//
//	public int getDay() {
//		return day;
//	}
//
//	public void setDay(int day) {
//		this.day = day;
//	}
//	public int getEventid() {
//		return eventid;
//	}
//	public void setEventid(int eventid) {
//		this.eventid = eventid;
//	}
//	
}
